package com.androider.timememory.adapter;

import com.androider.timememory.R;
import com.androider.timememory.utils.StringUtil;
import com.androider.timememory.view.TitleProvider;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class DiffAdapter extends BaseAdapter implements TitleProvider {

        private static final int VIEW_NEW_RECORD = 0;
        private static final int VIEW_WELCOME = 1;
        private static final int VIEW_FAMILY = 2;
        private static final int VIEW_LOVER = 3;
        private static final int VIEW_FRIEND = 4;
        private static final int VIEW_MAX_COUNT = VIEW_FRIEND + 1;
        private Context mContext;

    private LayoutInflater mInflater;

    public DiffAdapter(Context context) {
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mContext = context;
    }

    @Override
    public int getItemViewType(int position) {
        return position;
    }

    @Override
    public int getViewTypeCount() {
        return VIEW_MAX_COUNT;
    }

    @Override
    public int getCount() {
        return 5;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        int view = getItemViewType(position);
        if (convertView == null) {
            switch (view) {
                case VIEW_NEW_RECORD:
                    convertView = mInflater.inflate(R.layout.new_note, null);
                    break;
                case VIEW_WELCOME:
                    convertView = mInflater.inflate(R.layout.welcome, null);
                    break;
                case VIEW_FAMILY:
                	convertView = mInflater.inflate(R.layout.list_family, null);
                	break;
                case VIEW_LOVER:
                	convertView = mInflater.inflate(R.layout.list_lover, null);
                	break;
                case VIEW_FRIEND:
                	convertView = mInflater.inflate(R.layout.list_friend, null);
                	break;
            }
        }
        return convertView;
    }

    
    /* (non-Javadoc)
	 * @see org.taptwo.android.widget.TitleProvider#getTitle(int)
	 */
	public String getTitle(int position) {
		return StringUtil.getTitles(mContext).get(position);
	}

}
